package com.link2room.bumblebee;

import com.link2room.common.mnsLog.RedisMsgHandler;
import com.link2room.common.mnsLog.listener.RedisQueueListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

import static com.link2room.common.mnsLog.impl.RedisQueueConstant.REDIS_KEY_CONSUMER;
import static com.link2room.common.mnsLog.impl.RedisQueueConstant.REDIS_KEY_PRODUCTER;

/**
 * 加载redis消息服务轮询服务

 */
@Component  //使用时，打开注释
public class ReidsQueuePollingStartupRunner implements CommandLineRunner {

    @Resource //需要实现此接口
    private RedisMsgHandler mnsConsumerLogQueueHandler;
    @Resource
    private RedisMsgHandler mnsProducterLogQueueHandler;

    @Resource
    private RedisQueueListener redisQueueListener;

    private static Logger logger = LoggerFactory.getLogger(ReidsQueuePollingStartupRunner.class);
    @Override
    public void run(String... strings) throws Exception {
        redisQueueListener.startPolling(REDIS_KEY_CONSUMER,mnsConsumerLogQueueHandler,5);
        redisQueueListener.startPolling(REDIS_KEY_PRODUCTER,mnsProducterLogQueueHandler,5);
    }
}
